package com.ming.Service;

import com.ming.Bean.User;
import com.ming.Mapper.UserMapper;
import com.sun.org.apache.bcel.internal.ExceptionConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author:weiming
 * @Date:2020/11/25
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;


    @Override
    @Transactional(rollbackFor = {Exception.class})
    public int saveUser(User s) throws Exception {
        userMapper.saveUser(s);
        if("weiming".equals(s.getUsername())){
                throw new Exception("不能重复插入数据");
        }
        return 0;
    }
}
